
import request from "@/utils/request.js";


export function uploadFile(file){
    const formData = new FormData();
    formData.append('file', file); // 与后端@RequestParam("file")对应
    return request({
        url: '/files/upload',
        method: 'post',
        data: formData,
        responseType: 'json'
        // headers: { 'Content-Type': 'multipart/form-data' },//浏览器会自动生成
        // onUploadProgress: (progressEvent) => {
        //     // 上传进度（可选：通过store传递给组件）
        //     const progress = (progressEvent.loaded / progressEvent.total) * 100;
        //     console.log('上传进度：', progress);
        // }
    });
}